package org.dfl.plugin.editor.figures;

import org.eclipse.draw2d.Ellipse;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Rectangle;

/**
 * figure of a place
 * @author Piotr Wlodarczyk
 *
 */
public class PlaceFigure extends Ellipse {
	private Label label = new Label();
	private Label tip = new Label();

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public PlaceFigure(String text,String tipText){
		super();
		this.setOpaque(true); // transparent for label
		this.setBackgroundColor(FiguresConstants.placeColorNoData);
		label.setFont(FiguresConstants.placeFont);
		
		// ustawianie labela
		this.setLabelText(text);
		label.setOpaque(false); // transparent label
//		label.setLabelAlignment(PositionConstants.LEFT);
//		label.setTextAlignment(PositionConstants.TOP);
		label.setToolTip(tip);
		
		this.setTipText(tipText);
		this.add(label);
	}
	
	public String getLabelText() {
		return label.getText();
	}
	
	public void setLabelText(String text) {
		label.setText(text);
	}	
	
	public String getTipText() {
		return tip.getText();
	}
	
	public void setTipText(String text) {
		tip.setText(text);
	}	
	
	@Override
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		Rectangle nrect = new Rectangle();
		nrect.height = rect.height;
		nrect.width = rect.width-10;
		nrect.x = rect.x+5;
		nrect.y = rect.y;
		label.setBounds(nrect); // settng label size
	}
}
